Cleanup naming for ia64 and x86 interrupt handling functions
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 12 Feb 2009 10:48:55 +0000 (10:48 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 12 Feb 2009 10:48:55 +0000 (10:48 +0000)
- Append '_IRQ' to AUTO_ASSIGN, NEVER_ASSIGN, and FREE_TO_ASSIGN
- Rename {request,setup}_irq to {request,setup}_irq_vector
- Rename free_irq to release_irq_vector
- Add {request,setup,release}_irq wrappers for their
  {request,setup,release}_irq_vector counterparts
- Added generic irq_to_vector inline for ia64
- Changed ia64 to use the new naming scheme

Signed-off-by: Espen Skoglund <espen.skoglund@netronome.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
18 files changed:
xen/arch/ia64/linux-xen/iosapic.c
xen/arch/ia64/linux-xen/irq_ia64.c
xen/arch/ia64/linux-xen/mca.c
xen/arch/ia64/xen/hypercall.c
xen/arch/ia64/xen/irq.c
xen/arch/x86/i8259.c
xen/arch/x86/irq.c
xen/arch/x86/physdev.c
xen/drivers/char/serial.c
xen/drivers/passthrough/amd/iommu_init.c
xen/drivers/passthrough/vtd/ia64/vtd.c
xen/drivers/passthrough/vtd/iommu.c
xen/include/asm-ia64/hvm/iommu.h
xen/include/asm-ia64/hvm/irq.h
xen/include/asm-ia64/linux-xen/linux/interrupt.h
xen/include/asm-ia64/linux/asm/hw_irq.h
xen/include/asm-x86/irq.h
xen/include/xen/irq.h

index b6065f741084d91e09c35261a6b779adeadcda49..6d187f84fb1227140998cfddcd01313e1acad302 100644 (file)
 #include <asm/ptrace.h>
 #include <asm/system.h>
 
+#ifdef XEN
+static inline int iosapic_irq_to_vector (int irq)
+{
+       return irq;
+}
+
+#undef irq_to_vector
+#define irq_to_vector(irq)      iosapic_irq_to_vector(irq)
+#define AUTO_ASSIGN    AUTO_ASSIGN_IRQ
+#endif
 
 #undef DEBUG_INTERRUPT_ROUTING
 
index 754c6ea36719c1f52e00129dfc44ab5425e5abac..4a782fb33c27bd65464460de8dfdbc013f0150bb 100644 (file)
@@ -250,6 +250,7 @@ void
 register_percpu_irq (ia64_vector vec, struct irqaction *action)
 {
        irq_desc_t *desc;
+#ifndef XEN
        unsigned int irq;
 
        for (irq = 0; irq < NR_IRQS; ++irq)
@@ -258,16 +259,19 @@ register_percpu_irq (ia64_vector vec, struct irqaction *action)
                        desc->status |= IRQ_PER_CPU;
                        desc->handler = &irq_type_ia64_lsapic;
                        if (action)
-#ifdef XEN
-                               setup_vector(irq, action);
-#else
                                setup_irq(irq, action);
-#endif
                }
+#else
+       desc = irq_descp(vec);
+       desc->status |= IRQ_PER_CPU;
+       desc->handler = &irq_type_ia64_lsapic;
+       if (action)
+               setup_vector(vec, action);
+#endif
 }
 
 #ifdef XEN
-int request_irq(unsigned int irq,
+int request_irq_vector(unsigned int vector,
                void (*handler)(int, void *, struct cpu_user_regs *),
                unsigned long irqflags, const char * devname, void *dev_id)
 {
@@ -279,7 +283,7 @@ int request_irq(unsigned int irq,
         * otherwise we'll have trouble later trying to figure out
         * which interrupt is which (messes up the interrupt freeing logic etc).
         *                          */
-       if (irq >= NR_IRQS)
+       if (vector >= NR_VECTORS)
                return -EINVAL;
        if (!handler)
                return -EINVAL;
@@ -291,7 +295,7 @@ int request_irq(unsigned int irq,
        action->handler = handler;
        action->name = devname;
        action->dev_id = dev_id;
-       setup_vector(irq, action);
+       setup_vector(vector, action);
        if (retval)
                xfree(action);
 
index 3abef0bf31cbe8396bbd214ece239505264a6971..a1af73f5aeda939c28d1707691d2fc206fc73974 100644 (file)
@@ -114,7 +114,6 @@ extern void                 ia64_monarch_init_handler (void);
 extern void                    ia64_slave_init_handler (void);
 #ifdef XEN
 extern void setup_vector (unsigned int vec, struct irqaction *action);
-#define setup_irq(irq, action) setup_vector(irq, action)
 #endif
 
 static ia64_mc_info_t          ia64_mc_info;
@@ -1922,12 +1921,18 @@ ia64_mca_late_init(void)
                if (cpe_vector >= 0) {
                        /* If platform supports CPEI, enable the irq. */
                        cpe_poll_enabled = 0;
+#ifndef XEN
                        for (irq = 0; irq < NR_IRQS; ++irq)
                                if (irq_to_vector(irq) == cpe_vector) {
                                        desc = irq_descp(irq);
                                        desc->status |= IRQ_PER_CPU;
-                                       setup_irq(irq, &mca_cpe_irqaction);
+                                       setup_vector(irq, &mca_cpe_irqaction);
                                }
+#else
+                       desc = irq_descp(cpe_vector);
+                       desc->status |= IRQ_PER_CPU;
+                       setup_vector(cpe_vector, &mca_cpe_irqaction);
+#endif
                        ia64_mca_register_cpev(cpe_vector);
                        IA64_MCA_DEBUG("%s: CPEI/P setup and enabled.\n", __FUNCTION__);
                } else {
index d6151a2f1b01ae21af900f1764e67e1133948867..a5828b1816445fcae056aa6d97f12ce125239854 100644 (file)
@@ -543,7 +543,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg)
             break;
         irq_status_query.flags = 0;
         /* Edge-triggered interrupts don't need an explicit unmask downcall. */
-        if ( !strstr(irq_desc[irq_to_vector(irq)].handler->typename, "edge") )
+        if ( !strstr(irq_descp(irq)->handler->typename, "edge") )
             irq_status_query.flags |= XENIRQSTAT_needs_eoi;
         ret = copy_to_guest(arg, &irq_status_query, 1) ? -EFAULT : 0;
         break;
index aa4ed88242d1b8323314ded7b5555c1cde1bbe90..bce8c6c237dad2ae331ddff78e9b8c1a15792ab2 100644 (file)
@@ -228,11 +228,11 @@ out:
  * disabled.
  */
 
-int setup_vector(unsigned int irq, struct irqaction * new)
+int setup_vector(unsigned int vector, struct irqaction * new)
 {
        unsigned long flags;
        struct irqaction *old, **p;
-       irq_desc_t *desc = irq_descp(irq);
+       irq_desc_t *desc = irq_descp(vector);
 
        /*
         * The following block of code has to be executed atomically
@@ -248,8 +248,8 @@ int setup_vector(unsigned int irq, struct irqaction * new)
 
        desc->depth = 0;
        desc->status &= ~(IRQ_DISABLED | IRQ_INPROGRESS | IRQ_GUEST);
-       desc->handler->startup(irq);
-       desc->handler->enable(irq);
+       desc->handler->startup(vector);
+       desc->handler->enable(vector);
        spin_unlock_irqrestore(&desc->lock,flags);
 
        return 0;
@@ -258,13 +258,11 @@ int setup_vector(unsigned int irq, struct irqaction * new)
 /* Vectors reserved by xen (and thus not sharable with domains).  */
 unsigned long ia64_xen_vector[BITS_TO_LONGS(NR_IRQS)];
 
-int setup_irq(unsigned int irq, struct irqaction * new)
+int setup_irq_vector(unsigned int vec, struct irqaction * new)
 {
-       unsigned int vec;
        int res;
 
-       /* Get vector for IRQ.  */
-       if (acpi_gsi_to_irq (irq, &vec) < 0)
+       if ( vec == IA64_INVALID_VECTOR )
                return -ENOSYS;
        /* Reserve the vector (and thus the irq).  */
        if (test_and_set_bit(vec, ia64_xen_vector))
@@ -273,14 +271,12 @@ int setup_irq(unsigned int irq, struct irqaction * new)
        return res;
 }
 
-void free_irq(unsigned int irq)
+void release_irq_vector(unsigned int vec)
 {
-       unsigned int vec;
        unsigned long flags;
        irq_desc_t *desc;
 
-       /* Get vector for IRQ.  */
-       if (acpi_gsi_to_irq(irq, &vec) < 0)
+       if ( vec == IA64_INVALID_VECTOR )
                return;
 
        desc = irq_descp(vec);
index f945f5df648ff7d17cd56d9023a79a0f76f44ac3..29cd86ee3a52ab95233b5562a36c5112b19fa8e6 100644 (file)
@@ -410,8 +410,8 @@ void __init init_IRQ(void)
     }
 
     /* Never allocate the hypercall vector or Linux/BSD fast-trap vector. */
-    vector_irq[HYPERCALL_VECTOR] = NEVER_ASSIGN;
-    vector_irq[0x80] = NEVER_ASSIGN;
+    vector_irq[HYPERCALL_VECTOR] = NEVER_ASSIGN_IRQ;
+    vector_irq[0x80] = NEVER_ASSIGN_IRQ;
 
     apic_intr_init();
 
index 2587b0736c09c83ee52916bd175998a360ae5a66..6c5b6ad3955236f5d08e3e587ae0f00cc7884faf 100644 (file)
@@ -29,7 +29,7 @@ irq_desc_t irq_desc[NR_VECTORS];
 
 static DEFINE_SPINLOCK(vector_lock);
 int vector_irq[NR_VECTORS] __read_mostly = {
-    [0 ... NR_VECTORS - 1] = FREE_TO_ASSIGN
+    [0 ... NR_VECTORS - 1] = FREE_TO_ASSIGN_IRQ
 };
 
 static void __do_IRQ_guest(int vector);
@@ -66,11 +66,11 @@ int free_irq_vector(int vector)
     BUG_ON((vector > LAST_DYNAMIC_VECTOR) || (vector < FIRST_DYNAMIC_VECTOR));
 
     spin_lock(&vector_lock);
-    if ((irq = vector_irq[vector]) == AUTO_ASSIGN)
-        vector_irq[vector] = FREE_TO_ASSIGN;
+    if ((irq = vector_irq[vector]) == AUTO_ASSIGN_IRQ)
+        vector_irq[vector] = FREE_TO_ASSIGN_IRQ;
     spin_unlock(&vector_lock);
 
-    return (irq == AUTO_ASSIGN) ? 0 : -EINVAL;
+    return (irq == AUTO_ASSIGN_IRQ) ? 0 : -EINVAL;
 }
 
 int assign_irq_vector(int irq)
@@ -82,13 +82,13 @@ int assign_irq_vector(int irq)
 
     spin_lock(&vector_lock);
 
-    if ((irq != AUTO_ASSIGN) && (IO_APIC_VECTOR(irq) > 0)) {
+    if ((irq != AUTO_ASSIGN_IRQ) && (IO_APIC_VECTOR(irq) > 0)) {
         spin_unlock(&vector_lock);
         return IO_APIC_VECTOR(irq);
     }
 
     vector = current_vector;
-    while (vector_irq[vector] != FREE_TO_ASSIGN) {
+    while (vector_irq[vector] != FREE_TO_ASSIGN_IRQ) {
         vector += 8;
         if (vector > LAST_DYNAMIC_VECTOR)
             vector = FIRST_DYNAMIC_VECTOR + ((vector + 1) & 7);
@@ -101,7 +101,7 @@ int assign_irq_vector(int irq)
 
     current_vector = vector;
     vector_irq[vector] = irq;
-    if (irq != AUTO_ASSIGN)
+    if (irq != AUTO_ASSIGN_IRQ)
         IO_APIC_VECTOR(irq) = vector;
 
     spin_unlock(&vector_lock);
@@ -159,7 +159,7 @@ asmlinkage void do_IRQ(struct cpu_user_regs *regs)
     spin_unlock(&desc->lock);
 }
 
-int request_irq(unsigned int irq,
+int request_irq_vector(unsigned int vector,
         void (*handler)(int, void *, struct cpu_user_regs *),
         unsigned long irqflags, const char * devname, void *dev_id)
 {
@@ -172,7 +172,7 @@ int request_irq(unsigned int irq,
      * which interrupt is which (messes up the interrupt freeing
      * logic etc).
      */
-    if (irq >= NR_IRQS)
+    if (vector >= NR_VECTORS)
         return -EINVAL;
     if (!handler)
         return -EINVAL;
@@ -185,17 +185,16 @@ int request_irq(unsigned int irq,
     action->name = devname;
     action->dev_id = dev_id;
 
-    retval = setup_irq(irq, action);
+    retval = setup_irq_vector(vector, action);
     if (retval)
         xfree(action);
 
     return retval;
 }
 
-void free_irq(unsigned int irq)
+void release_irq_vector(unsigned int vector)
 {
-    unsigned int  vector = irq_to_vector(irq);
-    irq_desc_t   *desc = &irq_desc[vector];
+    irq_desc_t *desc = &irq_desc[vector];
     unsigned long flags;
 
     spin_lock_irqsave(&desc->lock,flags);
@@ -209,10 +208,9 @@ void free_irq(unsigned int irq)
     do { smp_mb(); } while ( desc->status & IRQ_INPROGRESS );
 }
 
-int setup_irq(unsigned int irq, struct irqaction *new)
+int setup_irq_vector(unsigned int vector, struct irqaction *new)
 {
-    unsigned int  vector = irq_to_vector(irq);
-    irq_desc_t   *desc = &irq_desc[vector];
+    irq_desc_t *desc = &irq_desc[vector];
     unsigned long flags;
  
     spin_lock_irqsave(&desc->lock,flags);
index 794632c0536f80803caa01a0a63302f358febbac..9c55237a018df1ad147bff5279cbc56739dc1fe7 100644 (file)
@@ -75,7 +75,7 @@ static int physdev_map_pirq(struct physdev_map_pirq *map)
         case MAP_PIRQ_TYPE_MSI:
             vector = map->index;
             if ( vector == -1 )
-                vector = assign_irq_vector(AUTO_ASSIGN);
+                vector = assign_irq_vector(AUTO_ASSIGN_IRQ);
 
             if ( vector < 0 || vector >= NR_VECTORS )
             {
index cc8440fab21cf969b99a7b9fe8e00f53c3c17b99..3d261caa47a2cf2f973394e0df2dbcebe66dec19 100644 (file)
@@ -471,7 +471,7 @@ void serial_suspend(void)
     int i, irq;
     for ( i = 0; i < ARRAY_SIZE(com); i++ )
         if ( (irq = serial_irq(i)) >= 0 )
-            free_irq(irq);
+            release_irq(irq);
 }
 
 void serial_resume(void)
index ecdb5b3b5e820b1f0f97c6fca5a8159309de5ed6..29510351081b934376e253811e4eb6cca0d7e76c 100644 (file)
@@ -479,7 +479,7 @@ static int set_iommu_interrupt_handler(struct amd_iommu *iommu)
 {
     int vector, ret;
 
-    vector = assign_irq_vector(AUTO_ASSIGN);
+    vector = assign_irq_vector(AUTO_ASSIGN_IRQ);
     if ( vector <= 0 )
     {
         gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: no vectors\n");
@@ -487,7 +487,8 @@ static int set_iommu_interrupt_handler(struct amd_iommu *iommu)
     }
 
     irq_desc[vector].handler = &iommu_msi_type;
-    ret = request_irq(vector, amd_iommu_page_fault, 0, "amd_iommu", iommu);
+    ret = request_irq_vector(vector, amd_iommu_page_fault, 0,
+                             "amd_iommu", iommu);
     if ( ret )
     {
         irq_desc[vector].handler = &no_irq_type;
@@ -497,7 +498,7 @@ static int set_iommu_interrupt_handler(struct amd_iommu *iommu)
     }
 
     /* Make sure that vector is never re-used. */
-    vector_irq[vector] = NEVER_ASSIGN;
+    vector_irq[vector] = NEVER_ASSIGN_IRQ;
     vector_to_iommu[vector] = iommu;
     iommu->vector = vector;
     return vector;
index 64638b5b6cfd19efb4b1f7fd312e3de97bf796ba..ca0e116f3c50d900d8bfe6e3760016c1adb9847a 100644 (file)
@@ -29,7 +29,9 @@
 #include "../vtd.h"
 
 
-int vector_irq[NR_VECTORS] __read_mostly = { [0 ... NR_VECTORS - 1] = -1};
+int vector_irq[NR_VECTORS] __read_mostly = {
+    [0 ... NR_VECTORS - 1] = FREE_TO_ASSIGN_IRQ
+};
 /* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */
 u8 irq_vector[NR_IRQS] __read_mostly;
 
index 7237acbc496a7d1488bd4e7eb131ebeeecd44d39..7bc680eed8f03767c9a344de886f9545ee3d013f 100644 (file)
@@ -874,7 +874,7 @@ int iommu_set_interrupt(struct iommu *iommu)
 {
     int vector, ret;
 
-    vector = assign_irq_vector(AUTO_ASSIGN);
+    vector = assign_irq_vector(AUTO_ASSIGN_IRQ);
     if ( vector <= 0 )
     {
         gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: no vectors\n");
@@ -882,7 +882,7 @@ int iommu_set_interrupt(struct iommu *iommu)
     }
 
     irq_desc[vector].handler = &dma_msi_type;
-    ret = request_irq(vector, iommu_page_fault, 0, "dmar", iommu);
+    ret = request_irq_vector(vector, iommu_page_fault, 0, "dmar", iommu);
     if ( ret )
     {
         irq_desc[vector].handler = &no_irq_type;
@@ -892,7 +892,7 @@ int iommu_set_interrupt(struct iommu *iommu)
     }
 
     /* Make sure that vector is never re-used. */
-    vector_irq[vector] = NEVER_ASSIGN;
+    vector_irq[vector] = NEVER_ASSIGN_IRQ;
     vector_to_iommu[vector] = iommu;
 
     return vector;
@@ -970,7 +970,7 @@ static void iommu_free(struct acpi_drhd_unit *drhd)
         iounmap(iommu->reg);
 
     free_intel_iommu(iommu->intel);
-    free_irq(iommu->vector);
+    release_irq_vector(iommu->vector);
     xfree(iommu);
 
     drhd->iommu = NULL;
index 2a83da93a3c29eff0238ea0ad91d320e3054d2ab..f1b12f19f1d5371779e5210d3977d490874cffc1 100644 (file)
@@ -28,10 +28,6 @@ static inline void pci_cleanup_msi(struct pci_dev *pdev)
     /* TODO */
 }
 
-/* Special IRQ numbers */
-#define AUTO_ASSIGN     (-1)
-#define NEVER_ASSIGN    (-2)
-#define FREE_TO_ASSIGN  (-3)
 
 extern int assign_irq_vector (int irq);
 
index 758d8c7ddd69121f53c54aa857b04f8b523a1360..c16664d4491efd06710131d70d1dbbc2e703e1d6 100644 (file)
@@ -90,13 +90,17 @@ struct hvm_irq {
 #define hvm_pci_intx_link(dev, intx) \
     (((dev) + (intx)) & 3)
 
-/* Extract the IA-64 vector that corresponds to IRQ.  */
-static inline int
-irq_to_vector (int irq)
+#define IA64_INVALID_VECTOR    ((unsigned int)((int)-1))
+static inline unsigned int irq_to_vector(int irq)
 {
-    return irq;
-}
+    int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
+    unsigned int vector;
+
+    if ( acpi_gsi_to_irq(irq, &vector) < 0)
+        return 0;
 
+    return vector;
+}
 
 extern u8 irq_vector[NR_IRQS];
 extern int vector_irq[NR_VECTORS];
index 6f1aece4361ea477906fbe7534306553dc91d5b7..2990ace0a53c555e8dfb38a7432d594ab38d9eb5 100644 (file)
@@ -52,10 +52,10 @@ struct irqaction {
 };
 
 extern irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs);
-extern int request_irq(unsigned int,
+extern int request_irq_vector(unsigned int,
                       irqreturn_t (*handler)(int, void *, struct pt_regs *),
                       unsigned long, const char *, void *);
-extern void free_irq(unsigned int, void *);
+extern void release_irq_vector(unsigned int, void *);
 #endif
 
 
index 9ecf9014056613669cb879819d1e1b2aa89e36b5..579ec6a9e3261b056f9c61ce312e733d82721370 100644 (file)
@@ -34,7 +34,7 @@ typedef u8 ia64_vector;
 #define IA64_MAX_VECTORED_IRQ          255
 #define IA64_NUM_VECTORS               256
 
-#define AUTO_ASSIGN                    -1
+#define AUTO_ASSIGN_IRQ                        (-1)
 
 #define IA64_SPURIOUS_INT_VECTOR       0x0f
 
index 2f1e59f148aca880717f5d8834455b961663791a..108b065d17262782f440f821d7504d69d6064f0a 100644 (file)
@@ -19,9 +19,6 @@
 
 extern int vector_irq[NR_VECTORS];
 extern u8 irq_vector[NR_IRQS];
-#define AUTO_ASSIGN    -1
-#define NEVER_ASSIGN   -2
-#define FREE_TO_ASSIGN -3
 
 #define platform_legacy_irq(irq)       ((irq) < 16)
 
index 48a5079c44cc48968140c782d537e058de2c6715..f6b40c87476513cf76713d3158b9c32e6266f5fe 100644 (file)
@@ -25,6 +25,11 @@ struct irqaction
 #define IRQ_GUEST_EOI_PENDING 32 /* IRQ was disabled, pending a guest EOI */
 #define IRQ_PER_CPU     256     /* IRQ is per CPU */
 
+/* Special IRQ numbers. */
+#define AUTO_ASSIGN_IRQ         (-1)
+#define NEVER_ASSIGN_IRQ        (-2)
+#define FREE_TO_ASSIGN_IRQ      (-3)
+
 /*
  * Interrupt controller descriptor. This is all we need
  * to describe about the low-level hardware. 
@@ -64,12 +69,21 @@ typedef struct {
 
 extern irq_desc_t irq_desc[NR_VECTORS];
 
-extern int setup_irq(unsigned int, struct irqaction *);
-extern void free_irq(unsigned int);
-extern int request_irq(unsigned int irq,
+extern int setup_irq_vector(unsigned int, struct irqaction *);
+extern void release_irq_vector(unsigned int);
+extern int request_irq_vector(unsigned int vector,
                void (*handler)(int, void *, struct cpu_user_regs *),
                unsigned long irqflags, const char * devname, void *dev_id);
 
+#define setup_irq(irq, action) \
+    setup_irq_vector(irq_to_vector(irq), action)
+
+#define release_irq(irq) \
+    release_irq_vector(irq_to_vector(irq))
+
+#define request_irq(irq, handler, irqflags, devname, devid) \
+    request_irq_vector(irq_to_vector(irq), handler, irqflags, defname, devid)
+
 extern hw_irq_controller no_irq_type;
 extern void no_action(int cpl, void *dev_id, struct cpu_user_regs *regs);